package util;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import javax.microedition.rms.RecordComparator;



public class ComparadorNome implements RecordComparator {
	
	
	
	public int compare(byte[] reg1, byte[] reg2) {
		try {
			ByteArrayInputStream BAIS = new ByteArrayInputStream(reg1);
			DataInputStream DIS = new DataInputStream(BAIS);
			String nome1 = DIS.readUTF();
			DIS.close();
			BAIS.close();
			ByteArrayInputStream BAIS2 = new ByteArrayInputStream(reg2);
			DataInputStream DIS2 = new DataInputStream(BAIS2);

			String nome2 = DIS2.readUTF();
			DIS2.close();
			BAIS2.close();
			if (nome1.compareTo(nome2) < 0)
				return -1;
			if (nome1.compareTo(nome2) > 0)
				return 1;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}
	
	
}// fim da classe.